import clickhouse_connect

connect_info = {
    'port': 8123,
    'host': '192.168.2.121',
    'username': 'default',
    'password': '@Abcd1234',
    'database': 'saas_shyd'
}
client = clickhouse_connect.get_client(**connect_info)
sql00 = "show tables where name like 'dam_storage%'"
result00 = client.query(sql00)
tables = result00.result_rows
with open('D://test.txt', 'w', encoding='utf-8') as f:
    for table in tables:
        table_name = table[0]
        create_sql = f"show create table {table_name}"
        result = client.query(create_sql)
        f.write(result.result_rows[0][0])
        f.write('\n')
f.close()
client.close()
